/*

* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     Smart-Shop开源商城系统/ Java商城-首选电商平台系统 请务必保留此注释头信息
* |     开源地址: https://gitee.com/ningbo-qishan/gruul-mall
* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     可正常分享和学习源码,未经授权 不可商用！
* |     商业版中台购买/开源版商业授权 联系技术客服
* |     官网:  https://www.73app.cn/
* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     Copyright (c) 2016-2999 宁波启山智软科技有限公司
* |     版权所有 ,侵权必究！
* ------------------------------------------------------------------------

*/
package com.medusa.gruul.live.controller.manager;

import com.medusa.gruul.common.core.util.PageUtils;
import com.medusa.gruul.common.core.util.Result;
import com.medusa.gruul.live.model.vo.LiveVo;
import com.medusa.gruul.live.service.LiveService;
import com.medusa.gruul.live.model.param.manager.LiveParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.LinkedList;


/**
 * <p>
 * 直播表 前端控制器
 * </p>
 *
 * @author zhaokw
 * @since 2020-04-01
 */
@RestController
@RequestMapping("/manager")
@Api(tags = "直播接口")
public class LiveController {
    @Autowired
    private LiveService liveService;

    /**
     * 直播信息列表
     *
     * @param liveParam
     * @return
     */
    @GetMapping("/get/List")
    @ApiOperation(value = "直播信息")
    public Result<PageUtils<LiveVo>> getLiveList(LiveParam liveParam) {
        PageUtils<LiveVo> pageUtils = new PageUtils(liveService.selectLiveList(liveParam));
        return Result.ok(pageUtils);
    }

    /**
     * 从微信后台重新调取数据
     *
     * @param liveParam
     * @return
     */
    @GetMapping("/get/weChatList")
    @ApiOperation(value = "直播信息")
    public Result<PageUtils<LiveVo>> getWeChatLiveList(LiveParam liveParam) {
        PageUtils<LiveVo> pageUtils = new PageUtils(liveService.getWeChatLiveList(liveParam));
        return Result.ok(pageUtils);
    }


    /**
     * 直播信息修改
     *
     * @param liveParam 直播信息通过id修改
     * @return
     */
    @GetMapping("/update/launchArea")
    @ApiOperation(value = "直播信息修改")
    public Result updateLaunchArea(LiveParam liveParam) {
        liveService.updateLaunchArea(liveParam);
        return Result.ok();
    }



    /**
     * 分享小程序码获取
     *
     * @param liveParam 分享小程序码的获取
     * @return
     */
    @GetMapping("/get/shareCode")
    @ApiOperation(value = "小程序码获取")
    public Result shareCode(LiveParam liveParam) {
        liveService.shareCode();
        return Result.ok();
    }


    /**
     * 拖拽更新sort
     *
     * @param params
     * @return res
     */
    @PostMapping("/update/sort")
    @ApiOperation(value = "直播信息修改")
    public Result<Boolean> updateSort(@RequestBody LinkedList<LiveParam> params) {
        return Result.ok(liveService.updateSort(params));
    }

}
